Skip to content

feat(network): support hotplug/hotunplug of additional network interfaces#2187

Draft
loktev-d wants to merge 13 commits intomainfrom
feat/network/dynamic-network-interfaces
Draft

feat(network): support hotplug/hotunplug of additional network interfaces#2187
loktev-d wants to merge 13 commits intomainfrom
feat/network/dynamic-network-interfaces

Conversation

@loktev-d
Copy link
Copy Markdown
Contributor

@loktev-d loktev-d commented Apr 6, 2026

Description

Adds support for hotplugging and hotunplugging additional network interfaces (Network, ClusterNetwork) on running VMs without restart.

Changes

Comparator (pkg/controller/vmchange/comparator_pod_placement.go)

  • compareNetworks now classifies non-Main network add/remove as ActionApplyImmediate instead of ActionRestart. Main network changes still require restart. New helper isOnlyNonMainNetworksChanged treats nil/empty spec.networks as equivalent to having an implicit default Main, so the nil → [Main, additional] transition is also non-disruptive.

Apply path (pkg/controller/vm/internal/sync_kvvm.go)

  • For ActionApplyImmediate changes that touch networks, the controller now:
  1. Patches the running pod's network.deckhouse.io/networks-spec annotation directly so the SDN module creates/removes the tap before KubeVirt tries to attach it (KVVM template annotation changes don't propagate to a running pod).
  2. Waits for the SDN to report the interface as ready via network.deckhouse.io/networks-status (uses pod watcher to retrigger reconcile) — without this, virt-launcher panics with "Link not found" when libvirt tries to attach a tap that doesn't exist yet.
  3. Updates the KVVM, which KubeVirt then syncs to the VMI; virt-handler hotplugs the interface via libvirt.

KVVM builder (pkg/controller/kvbuilder/kvvm.go, kvvm_utils.go)

  • New SetNetworkInterfaceAbsent method sets State: virtv1.InterfaceStateAbsent on an interface to signal hotunplug to KubeVirt.

Why do we need it, and what problem does it solve?

Currently, adding or removing additional networks on a VM requires a full restart, which is disruptive for production workloads. With this PR users can attach/detach Network/ClusterNetwork interfaces on running VMs and the changes take effect in the guest OS without reboot.

What is the expected result?

  1. Create a VM with a Main network and wait for Running.
  2. Patch spec.networks to add a ClusterNetwork. The VM's NeedRestart field stays clear; the new interface appears in the guest OS within seconds.
  3. Patch spec.networks to remove the ClusterNetwork. The interface disappears from the guest OS without a restart.
  4. Adding/removing a Main network still requires a restart (AwaitingRestartToApplyConfiguration condition is set).

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: vm
type: feature
summary: support hotplug/hotunplug of additional network interfaces

Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
@loktev-d loktev-d marked this pull request as draft April 6, 2026 13:05
loktev-d added 8 commits April 6, 2026 16:46
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
@loktev-d loktev-d added the e2e/run Run e2e test on cluster of PR author label Apr 7, 2026
@deckhouse-BOaTswain
Copy link
Copy Markdown
Contributor

deckhouse-BOaTswain commented Apr 7, 2026

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Apr 7, 2026
loktev-d and others added 2 commits April 8, 2026 12:48
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
Signed-off-by: Daniil Loktev <70405899+loktev-d@users.noreply.github.com>
@loktev-d loktev-d added the e2e/run Run e2e test on cluster of PR author label Apr 8, 2026
@deckhouse-BOaTswain
Copy link
Copy Markdown
Contributor

deckhouse-BOaTswain commented Apr 8, 2026

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Apr 8, 2026
@loktev-d loktev-d added the e2e/run Run e2e test on cluster of PR author label Apr 9, 2026
@loktev-d loktev-d added this to the v1.8.0 milestone Apr 9, 2026
@loktev-d loktev-d added e2e/run Run e2e test on cluster of PR author and removed e2e/run Run e2e test on cluster of PR author labels Apr 9, 2026
@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Apr 9, 2026
@loktev-d loktev-d added the e2e/run Run e2e test on cluster of PR author label Apr 9, 2026
Signed-off-by: Daniil Loktev <lokt.daniil@gmail.com>
@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Apr 9, 2026
@loktev-d loktev-d added the e2e/run Run e2e test on cluster of PR author label Apr 9, 2026
@deckhouse-BOaTswain
Copy link
Copy Markdown
Contributor

deckhouse-BOaTswain commented Apr 9, 2026

Workflow has started.
Follow the progress here: Workflow Run

The target step completed with status: failure.

@deckhouse-BOaTswain deckhouse-BOaTswain removed the e2e/run Run e2e test on cluster of PR author label Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants